/*
 * Copyright (c) 2015 4 13
 * Name:wuPeiJi
 * QQ:757671834
 */

package kali.wpj.kali.model;

import android.content.Context;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import kali.wpj.kali.R;

public class MyAdapter extends BaseAdapter {
private ArrayList<Result> list;
private Context context;
private LayoutInflater layoutInflater;
	public MyAdapter(ArrayList<Result> list, Context context) {
	super();
	this.list = list;
	this.context = context;
	layoutInflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		System.out.println("long" + list.size());
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		View vi=view;

		vi=layoutInflater.inflate(R.layout.list_item, null);
		TextView txt_port=(TextView) vi.findViewById(R.id.txt_port);
		txt_port.setTextSize(TypedValue.COMPLEX_UNIT_SP,16.f);
		txt_port.setTextColor(0xFF333333);
		TextView txt_state=(TextView) vi.findViewById(R.id.txt_state);
		txt_state.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16.f);
		txt_state.setTextColor(0xFF333333);
		TextView txt_service=(TextView) vi.findViewById(R.id.txt_service);

		txt_service.setTextSize(TypedValue.COMPLEX_UNIT_SP,16.f);
		txt_service.setTextColor(0xFF333333);

		txt_port.setText(list.get(position).getPort());
		txt_state.setText(list.get(position).getState());
		txt_service.setText(list.get(position).getService());
			
		return vi;
	}

}
